﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

namespace HBPVPDruid.Misc
{
    public static class Misc
    {
        //public static void slog(string format, params object[] args) //use for slogging
        //{
        //    Logging.Write("[PVPDruid By SwInY] " + format, args);
        //}

        public static void slog(string format, params object[] args) //use for slogging
        {
            Logging.Write(System.Drawing.Color.DarkBlue, "[PVPDruid By SwInY] " + string.Format(format, args));
        }

        public static void DebugLog(string format, params object[] args)
        {
            //Logging.WriteDebug(System.Drawing.Color.DarkBlue, "[PVPDruid By SwInY] " + string.Format(format, args));
        }


        public static void CastLog(string SpellName, string PlayerName) //use for slogging
        {
            slog("Casting {0} on  {1}", SpellName, PlayerName);
            DebugLog("Casting {0} on  {1}", SpellName, PlayerName);
        }

        public static void CastLog(string SpellName) //use for slogging
        {
            slog("Casting {0}", SpellName);
            DebugLog("Casting {0}", SpellName);
        }


        public static bool HasSpellID(int SpellID)
        {
                foreach (var Pair in  ObjectManager.Me.Auras)
                {
                    if (Pair.Value.SpellId == SpellID)
                    {
                        return true;
                    }
                }
                return false;
        }


        public static class PVPMisc
        {
            /// <summary>
            /// Returns Number of Enemys around me ( dist 35 )
            /// </summary>
            public static int EnemysAroundMe
            {
                get
                {
                    if (!Battlegrounds.IsInsideBattleground) return 0;
                    return (int)(from Unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false)
                                 where Unit.IsAlive
                                 where Unit.Distance < 40
                                 where !Unit.IsFriendly
                                 where !Unit.IsPet
                                 where Unit.InLineOfSight
                                 select Unit).Count();
                }
            }

            /// <summary>
            /// Returns Number of team mates around me ( dist 35 )
            /// </summary>
            public static int TeamAroundMe
            {
                get
                {
                    if (!Battlegrounds.IsInsideBattleground) return 0;
                    return (int)(from Unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false)
                                 where Unit.IsAlive
                                 where Unit.Distance < 35
                                 where Unit.IsFriendly
                                 where !Unit.IsPet
                                 where Unit.InLineOfSight
                                 select Unit).Count();
                }
            }

            /// <summary>
            /// Returns Amount of Melee Attacking me
            /// </summary>
            public static int MeleeAttackingMe
            {
                get
                {
                    if (!Battlegrounds.IsInsideBattleground) return 0;
                    return (int)(from Unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false)
                                 where Unit.IsAlive
                                 where Unit.Distance < 15
                                 where !Unit.IsFriendly
                                 where Unit.Class == WoWClass.DeathKnight || Unit.Class == WoWClass.Paladin || Unit.Class == WoWClass.Rogue || Unit.Class == WoWClass.Warrior
                                 where Unit.IsTargetingMeOrPet
                                 where !Unit.IsPet
                                 where Unit.InLineOfSight
                                 select Unit).Count();
                }
            }

            public static int EnemyAttackingMe
            {
                get
                {
                    if (!Battlegrounds.IsInsideBattleground) return 0;
                    return (int)(from Unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false)
                                 where Unit.IsAlive
                                 where Unit.Distance < 35
                                 where !Unit.IsFriendly
                                 where Unit.IsTargetingMeOrPet
                                 where !Unit.IsPet
                                 where Unit.InLineOfSight
                                 select Unit).Count();
                }
            }
        }



        public static class NPCMisc
        {
            public static int EnemyAttackingMe
            {
                get
                {
                    if (Battlegrounds.IsInsideBattleground) return 0;
                    return (int)(from Unit in ObjectManager.GetObjectsOfType<WoWUnit>(false)
                                 where Unit.IsAlive
                                 where Unit.Distance < 35
                                 where !Unit.IsFriendly
                                 where Unit.IsTargetingMeOrPet
                                 where !Unit.IsPet
                                 where Unit.InLineOfSight
                                 select Unit).Count();
                }
            }
        }

    }
}


